/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ComicActions.java
 *
 * Created on 17 déc. 2011, 19:04:00
 */
package MVC;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;
import protocol.ChatMessage;

/**
 *
 * @author Martin
 */
// Le "ComicActions" va envoyer le message lui même
public class ComicActions extends javax.swing.JFrame {

    private ChatGui mon_gui;
    private ChatController mon_controller;
    private ChatModel mon_model;
    
    String mon_string = null;
    ChatMessage mon_message = null;
    String distant_user = null;

    /** Creates new form ComicActions */
    public ComicActions(ChatGui aThis, ChatController controller, ChatModel model) {
        this.mon_gui = aThis;
        this.mon_model = model;
        this.mon_controller = controller;

        distant_user = (String) mon_gui.getSelectedValue();
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Action 1");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Action 2");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });

        jButton3.setText("Action 3");
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton3MouseClicked(evt);
            }
        });
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Action 4");
        jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton4MouseClicked(evt);
            }
        });

        jButton5.setText("Action 5");
        jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton5MouseClicked(evt);
            }
        });

        jButton6.setText("Action 6");
        jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton6MouseClicked(evt);
            }
        });

        jButton7.setText("Action 7");
        jButton7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton7MouseClicked(evt);
            }
        });

        jButton8.setText("Action 8");
        jButton8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton8MouseClicked(evt);
            }
        });

        jButton9.setText("Action 9");
        jButton9.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton9MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jButton1)
                .addGap(18, 18, 18)
                .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jButton3))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jButton4)
                .addGap(18, 18, 18)
                .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jButton6))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jButton7)
                .addGap(18, 18, 18)
                .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jButton9))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton3)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton4)
                    .addComponent(jButton6)
                    .addComponent(jButton5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton9)
                    .addComponent(jButton8)
                    .addComponent(jButton7))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton3ActionPerformed

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton1MouseClicked

private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton2MouseClicked

private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton3MouseClicked

private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton4MouseClicked

private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton5MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton5MouseClicked

private void jButton6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton6MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton6MouseClicked

private void jButton7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton7MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton7MouseClicked

private void jButton8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton8MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton8MouseClicked

private void jButton9MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton9MouseClicked
    try {
        mon_string = mon_model.getMon_username() + " attrape " + distant_user;
        mon_message = new ChatMessage(distant_user, mon_string, InetAddress.getLocalHost());
        mon_controller.send(distant_user, mon_message);
        this.dispose();
    } catch (UnknownHostException ex) {
        System.out.println("Erreur lors de l'envoi du message associe a la Comic Action 1 !");
    }
}//GEN-LAST:event_jButton9MouseClicked
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    // End of variables declaration//GEN-END:variables
}
